package com.ruoyi.warehouse.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.warehouse.mapper.WareHouseTankMapper;
import com.ruoyi.warehouse.domain.WareHouseTank;
import com.ruoyi.warehouse.service.IWareHouseTankService;

import java.util.List;
import java.util.Map;

/**
 * 仓库中心=>鱼缸Service业务层处理
 *
 * @author 杨彬鑫
 * @date 2021-01-29
 */
@Service
public class WareHouseTankServiceImpl extends ServiceImpl<WareHouseTankMapper, WareHouseTank> implements IWareHouseTankService {

    @Override
    public List<WareHouseTank> queryList(WareHouseTank wareHouseTank) {
        LambdaQueryWrapper<WareHouseTank> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(wareHouseTank.getTankName())){
            lqw.like(WareHouseTank::getTankName ,wareHouseTank.getTankName());
        }
        if (wareHouseTank.getTankType() != null){
            lqw.eq(WareHouseTank::getTankType ,wareHouseTank.getTankType());
        }
        if (StringUtils.isNotBlank(wareHouseTank.getTankSize())){
            lqw.eq(WareHouseTank::getTankSize ,wareHouseTank.getTankSize());
        }
        if (wareHouseTank.getTankCount() != null){
            lqw.eq(WareHouseTank::getTankCount ,wareHouseTank.getTankCount());
        }
        if (wareHouseTank.getTankBuyDates() != null){
            lqw.ge(WareHouseTank::getTankBuyDate,wareHouseTank.getTankBuyDates()[0]);
            lqw.le(WareHouseTank::getTankBuyDate,wareHouseTank.getTankBuyDates()[1]);
        }
        return this.list(lqw);
    }
}
